<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<jsp:useBean id="utilities" class="masterpiece.util.Utilities" scope="session" />    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Update Article</title>
<link rel="stylesheet" type="text/css" href="css/default.css" />
</head>
<body>
<%@ include file="top_menu.jsp" %>
<%int id = Integer.parseInt(request.getParameter("articleid"));
String ePass = request.getParameter("ePass");
String headline = request.getParameter("headline");
String subheadline = request.getParameter("subheadline");;
int section = Integer.parseInt(request.getParameter("section"));
String body = request.getParameter("body");
java.sql.Date issue = (java.sql.Date.valueOf(request.getParameter("issue")));
int rank = Integer.parseInt(request.getParameter("rank"));
int status = Integer.parseInt(request.getParameter("status"));


	if (utilities.allowedToEdit(ePass, id, status)){ 
		try{
		utilities.updateHeadline(id, headline);
		utilities.updateSubHeadline(id,subheadline);
		utilities.updateBody(id, body);
		utilities.updateSection(id, section);
		utilities.updateRank(id, rank);
		utilities.updateStatus(id, status);
		utilities.updateIssue(id, issue);
		utilities.updateWordCount(id, body);
		if (utilities.checkEditPrimaryKey(ePass, id))
			utilities.insertEdit(ePass, id);
		out.println("<p class=\"message success\">Article updated successfully.</p>");
		}catch(Exception e){
			out.println("<p class=\"message error\">Error updating article: "+e.toString()+"</p>");
		}
	}else{
		out.println("That is not a valid ePass to edit this article");
	}
%>
<a href="findupdatearticle.jsp">Back to update article list</a>
<%

%>


</body>
</html>